package cn.fufeiii.bt.common.util.result;

import cn.fufeiii.bt.common.code.CommonResultEnum;
import lombok.Data;

import java.util.Collection;


/**
 * 分页响应结果
 *
 * @author FuFei
 */
@Data
public final class PageResult<T> {

    private final boolean success;
    private final Integer code;
    private final String message;
    private final Collection<T> data;
    private final long total;

    private PageResult(Collection<T> data, long total) {
        this.success = true;
        this.code = CommonResultEnum.SERVER_SUCCESS.getCode();
        this.message = CommonResultEnum.SERVER_SUCCESS.getMessage();
        this.data = data;
        this.total = total;
    }

    public static <T> PageResult<T> success(Collection<T> data, long total) {
        return new PageResult<>(data, total);
    }

}